/*
 * @Description:
 * @Author: mmzhang
 * @Date: 2021-12-10 16:52:09
 * @LastEditTime: 2022-06-22 10:23:31
 */
import businessCommonMgr from '@/biz/businessReport/businessCommon'
import clueMgr from '@/biz/businessReport/clue'
import houseOpt from '@/biz/option/house.js'
import nameOpt from '@/biz/option/name.js'
import ruleOpt from '@/biz/option/rule.js'
import tool from '@/common/tool.js'
import Opt from '@/components/dt/info/Opt.js'

let _this = null
let companys = []
class SearchOpt extends Opt {
  constructor(vm) {
    _this = vm
    super()
    this.build()
  }

  getCompany() {
    let opt = {
      title: '组织筛选',
      key: 'officeIds',
      placeholder: '全部',
      tree: {
        options: companys
      }
    }
    let params = {
      isTwoLevel: true
    }
    businessCommonMgr.getOrgThreeTree(params).then((res) => {
      companys = res
      opt.tree.options = companys
    })
    return opt
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
      this.getCompany(),
      houseOpt.create({
        title: '推送案场',
        placeholder: '请输入推送案场',
        to: (info) => {
          return {
            buildingName: info.housesName
          }
        }
      })
    ]
  }
}

export default SearchOpt
